define([
	"static/app/tips",
	"UtilDir/util",
	"UtilDir/tool",
    "UtilDir/org/selectOrg",
    "UtilDir/searchBlock",
	"http://api.tianditu.gov.cn/api?v=4.0&tk=aeb17a8215786a5dd17f5f9c92bebc0c",
	"Date","DateCN", "css!DateCss",
	"EasyUI","EasyUI-lang"
    ],function(tips, Util, Tool, SelectOrg, SearchBlock){

    var sysPath =  getServer() + "/static/app/zdyh/yhdisasterhiddenLevel";

    var yhDisasterHiddenLevelFormHtml = sysPath + "/views/yhDisasterHiddenLevelForm.html";
	var getYhDisasterHiddenLevelController = function(){
		return getServer() + "/yhDisasterHiddenLevels";
	};

	/**
	 * 页面初始化
	 */
	var init = function(){
		initMap()
        initSearchBlock();
        queryBtnBind();
		createYhDisasterHiddenLevelGrid();
	};


	var initSearchBlock = function(){
        SearchBlock.init("searchBlock");
	};
	var queryBtnBind = function(){
        $("#btnSearch").click(function () {
            createYhDisasterHiddenLevelGrid();
        });
        $("#btnReset").click(function () {
			$("#addressCondition").val("");
			});
	};
	var createYhDisasterHiddenLevelGrid= function() {
        $("#yhDisasterHiddenLevelGrid").datagrid({
            url:getYhDisasterHiddenLevelController() + "/queryYhDisasterHiddenLevels",
			method:"GET",
            fitColumns: true,
            autoRowHeight: false,
            columns:[[
				{
					field:'address',
					title:'地址',
					width:'',
					align:'center',
				},
            ]],
            toolbar: [{
                iconCls: 'fa fa-plus-circle',
                text:"添加",
                handler: function(){
                    addYhDisasterHiddenLevel();
                }
            },{
                iconCls: 'fa fa-trash-o',
                text:"删除",
                handler: function(){
                    deleteYhDisasterHiddenLevel();
                }
            }],
            queryParams:{
				address: $("#addressCondition").val(),
            },
            pagination: true,
            pageSize: 10
        });
    };

	var initMap = function() {
		var mapH = document.body.clientHeight - $(".pd-search-container").height() - 10;
		$("#yhHiddenLevelMap").height(mapH);

		var vec_layer = new T.TileLayer("https://fxpc.mem.gov.cn/wmts?service=wmts&request=gettile&version=1.0.0&layer=vec&style=default&tilematrixset=c&format=tiles&tilematrix={z}&tilerow={y}&tilecol={x}");
		var cva_layer = new T.TileLayer("https://fxpc.mem.gov.cn/wmts?service=wmts&request=gettile&version=1.0.0&layer=cva&style=default&tilematrixset=c&format=tiles&tilematrix={z}&tilerow={y}&tilecol={x}");
		var config = {
			projection: 'EPSG:4326',
			minZoom: 4,
			layers: [vec_layer, cva_layer]
		};
		tdMap = new T.Map('yhHiddenLevelMap', config), zoom = 12;
		tdMap.centerAndZoom(new T.LngLat(116.40769, 39.89945), zoom);

		var control=new T.Control.Zoom();
		tdMap.addControl(control);

		//创建比例尺控件对象
		var scale = new T.Control.Scale();
		tdMap.addControl(scale);
	};



	return {
		init:init
	};
});
